package app.netant.book.ws65;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;

public class Ws65Detail extends BaseDetail {

	public Ws65Detail(String netSite) {
		super(netSite);
		this.preHref = "http://www.65ws.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select("section.bookinfo .info_t h1");
		if(parts.size()>0){
			String title = parts.get(0).text();
			int idx = title.indexOf("TXT");
			if(idx>0){
				title = title.substring(0,idx);
			}
			title = title.trim();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
		
		Elements parts2 = this.select("section.bookinfo .info_t span.author");
		if(parts2.size()>0){
			String writers = parts2.get(0).text();
			int idx = writers.indexOf("：");
			if(idx>0){
				writers = writers.substring(idx+1);
			}
			writers = writers.trim();
			System.out.println("【Writer】:"+writers);
			this.entity.setNovelWriter(writers);
		}
	}

	@Override
	public void analyseTags() {

	}

	@Override
	public void analyseMemo() {

	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".txtchapter ul div.book_read span.read_tj a");
		for(int i=0;i<parts.size();i++){
			String text = parts.get(i).text().trim();
			if("全文下载".equals(text)){
				String href = parts.get(i).attr("href");
				System.out.println("【Href】:"+href);
				this.entity.setDownPath(href);
			}
		}

	}
	
	@Override
	public void analyseType() {

	}
	
	public static void main(String[] args) {
		Ws65Detail detail = new Ws65Detail("http://www.65ws.com/packshow/78621/index.html");
		detail.test();
	}



}
